package com.lantian.uavmaterial.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lantian.common.annotation.Log;
import com.lantian.common.core.controller.BaseController;
import com.lantian.common.core.domain.AjaxResult;
import com.lantian.common.enums.BusinessType;
import com.lantian.uavmaterial.domain.UavPayloadCamera;
import com.lantian.uavmaterial.service.IUavPayloadCameraService;
import com.lantian.common.utils.poi.ExcelUtil;
import com.lantian.common.core.page.TableDataInfo;

/**
 * 任务载荷Controller
 * 
 * @author lantian
 * @date 2025-11-06
 */
@RestController
@RequestMapping("/uav/camera")
public class UavPayloadCameraController extends BaseController
{
    @Autowired
    private IUavPayloadCameraService uavPayloadCameraService;

    /**
     * 查询任务载荷列表
     */
    @PreAuthorize("@ss.hasPermi('uav:camera:list')")
    @GetMapping("/list")
    public TableDataInfo list(UavPayloadCamera uavPayloadCamera)
    {
        startPage();
        List<UavPayloadCamera> list = uavPayloadCameraService.selectUavPayloadCameraList(uavPayloadCamera);
        return getDataTable(list);
    }

    /**
     * 导出任务载荷列表
     */
    @PreAuthorize("@ss.hasPermi('uav:camera:export')")
    @Log(title = "任务载荷", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UavPayloadCamera uavPayloadCamera)
    {
        List<UavPayloadCamera> list = uavPayloadCameraService.selectUavPayloadCameraList(uavPayloadCamera);
        ExcelUtil<UavPayloadCamera> util = new ExcelUtil<UavPayloadCamera>(UavPayloadCamera.class);
        util.exportExcel(response, list, "任务载荷数据");
    }

    /**
     * 获取任务载荷详细信息
     */
    @PreAuthorize("@ss.hasPermi('uav:camera:query')")
    @GetMapping(value = "/{payloadCameraId}")
    public AjaxResult getInfo(@PathVariable("payloadCameraId") String payloadCameraId)
    {
        return success(uavPayloadCameraService.selectUavPayloadCameraByPayloadCameraId(payloadCameraId));
    }

    /**
     * 新增任务载荷
     */
    @PreAuthorize("@ss.hasPermi('uav:camera:add')")
    @Log(title = "任务载荷", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UavPayloadCamera uavPayloadCamera)
    {
        return toAjax(uavPayloadCameraService.insertUavPayloadCamera(uavPayloadCamera));
    }

    /**
     * 修改任务载荷
     */
    @PreAuthorize("@ss.hasPermi('uav:camera:edit')")
    @Log(title = "任务载荷", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UavPayloadCamera uavPayloadCamera)
    {
        return toAjax(uavPayloadCameraService.updateUavPayloadCamera(uavPayloadCamera));
    }

    /**
     * 删除任务载荷
     */
    @PreAuthorize("@ss.hasPermi('uav:camera:remove')")
    @Log(title = "任务载荷", businessType = BusinessType.DELETE)
	@DeleteMapping("/{payloadCameraIds}")
    public AjaxResult remove(@PathVariable String[] payloadCameraIds)
    {
        return toAjax(uavPayloadCameraService.deleteUavPayloadCameraByPayloadCameraIds(payloadCameraIds));
    }
}
